﻿using Acme.ConcreteMixDesign.Dtos;
using Acme.ConcreteMixDesign.Players;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace Acme.ConcreteMixDesign
{
    public class PlayerAppService : CrudAppService<Player,PlayerDto,Guid,PagedAndSortedResultRequestDto,CreatePlayerDto>, IPlayerAppService
    {

        private readonly IPlayerRepository _playerRepository;

        public PlayerAppService(IPlayerRepository playerRepository):base(playerRepository) 
        {
            _playerRepository = playerRepository;
        }

        public async Task<PlayerDto> GetLogin(LoginPlayerDto loginPlayerDto)
        {
            var player = await _playerRepository.FindAsync(
                e => e.accounts == loginPlayerDto.accounts && e.password == loginPlayerDto.password
                );
            if (player != null)
            return ObjectMapper.Map<Player, PlayerDto>(player);

            return null;
        }


        //public async Task<PagedResultDto<PlayerDto>> GetListPlayerPage(PagedAndSortedResultRequestDto input)
        //{
        //    var count = await _playerRepository.GetCountAsync();
        //    var list = await _playerRepository.GetPagedListAsync(
        //        input.SkipCount,
        //        input.MaxResultCount,
        //        input.Sorting);
        //    return new PagedResultDto<PlayerDto>
        //    {
        //        TotalCount = count,
        //        Items = ObjectMapper.Map<List<Player>, List<PlayerDto>>(list)
        //    };
        //}

        //public async Task<PlayerDto> GetPlayerAsync(Guid guid)
        //{
        //    var player = await _playerRepository.GetAsync(guid);
        //    return ObjectMapper.Map<Player, PlayerDto>(player);
        //}
    }
}
